/** 财务管理路由 */
import Layout from '@/views/layout/financeLayout'

// 待办事项
const backlogRouteItem = {
  path: 'backlogFinance', // 待办事项
  component: () => import('@/views/financemanagement/financemessage/Message'),
  meta: {
    requiresAuth: false,
    title: '待办事项',
    icon: 'yuzhen-message',
    index: 1,
    type: 'finance',
    num: 0
  }
}
// 采购管理
const purchaseAuth = {
  requiresAuth: true,
  index: 1,
  type: 'finance'
}

const materialRouteItem = {
  path: 'purchase', // 采购管理
  meta: {
    icon: 'el-icon-wallet',
    title: '采购管理',
    ...purchaseAuth
  },
  hidden: false,
  children: [{
    path: 'officePurchase', // 办公用品
    component: () => import('@/views/financemanagement/purchasemanagement/PurchaseIndex'),
    meta: {
      title: '办公用品',
      subType: 'officePurchase',
      ...purchaseAuth
    }
  }, {
    path: 'normalPurchase', // 常规备货
    component: () => import('@/views/financemanagement/purchasemanagement/PurchaseIndex'),
    meta: {
      title: '常规备货',
      subType: 'normalPurchase',
      ...purchaseAuth
    }
  }, {
    path: 'projectPurchase', // 项目备货
    component: () => import('@/views/financemanagement/purchasemanagement/PurchaseIndex'),
    meta: {
      title: '项目备货',
      subType: 'projectPurchase',
      ...purchaseAuth
    }
  }, {
    path: 'devPurchase', // 研发用品
    component: () => import('@/views/financemanagement/purchasemanagement/PurchaseIndex'),
    meta: {
      title: '研发用品',
      subType: 'devPurchase',
      ...purchaseAuth
    }
  }, {
    path: 'otherPurchase', // 其他
    component: () => import('@/views/financemanagement/purchasemanagement/PurchaseIndex'),
    meta: {
      title: '其他',
      subType: 'otherPurchase',
      ...purchaseAuth
    }
  }]
}

// 供应商管理
const storehouseRouteItem = {
  path: 'supplier', // 供应商管理
  component: () => import('@/views/financemanagement/supplierManagement/supplierIndex'),
  meta: {
    requiresAuth: true,
    title: '供应商',
    icon: 'el-icon-truck',
    index: 1,
    type: 'finance',
    subType: 'supplier'
  }
}

export const financeRouter = {
  path: '/finance',
  component: Layout,
  redirect: '/finance/backlogFinance',
  name: 'finance',
  hidden: true,
  meta: {
    requiresAuth: true,
    title: '财务管理',
    index: 0,
    type: 'finance'
  },
  children: [
    backlogRouteItem,
    ...materialRouteItem.children,
    storehouseRouteItem
  ]
}

export const financeRouterMenu = [
  backlogRouteItem,
  materialRouteItem,
  storehouseRouteItem
]
